/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.entidades;

import comum.Message;
import java.util.Observable;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author root
 */
public class Ping extends Observable implements Runnable {

    private Peer p;
    private long timeout;

    public Ping(Peer p, long timeout) {
        this.p = p;
        this.timeout = timeout;
    }

    @Override
    public void run() {
        p.transmitirMensagem(new Message(p.parent.getServerHost(), "PING", p.getStringName(), "LAG", true));
        setChanged();
        notifyObservers("pingou");
        try {
            Thread.sleep(timeout);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
        setChanged();
        notifyObservers();
    }
}
